import 'package:flutter_time_manager/state/model/todo.dart';
import 'package:intl/intl.dart';
import 'package:uuid/uuid.dart';

class TodoCollect {

  String id;

  DateTime dateTime;

  String dateTimeToLocal;

  String filePath;

  List<Todo> todoList;

  int index;

  TodoCollect({this.id, this.dateTime, this.todoList, this.filePath, this.index}) {
    this.dateTimeToLocal = DateFormat("MM/dd").format(this.dateTime);
    this.filePath = filePath == null ? "assets/image/${index + 1}.jpeg" : filePath;
    this.id = id == null ? Uuid().v4().replaceAll("-", "") : id;
    this.todoList = todoList == null ? [] : todoList;
  }

  static TodoCollect fromMap(Map<String, dynamic> map) {
    return TodoCollect(
      id: map["id"],
      dateTime: DateTime.fromMillisecondsSinceEpoch(map["dateTime"]),
      filePath: map["filePath"],
      index: map["indexNum"],
    );
  }

  @override
  String toString() {
    return 'TodoCollect{id: $id, dateTime: $dateTime, dateTimeToLocal: $dateTimeToLocal, filePath: $filePath, todoList: $todoList, index: $index}';
  }


}